<template>
	<view>
		<view class="cover">
			<image :src="castsList.avatars.small" mode="widthFix"></image>
			<view class="cast-infor">
				<text class="name">{{castsList.name}}</text>
				<text class="birthday">{{castsList.born_place}}</text>
			</view>
		</view>
		<view class="works">
			<view class="same-title wrap">
				<view class="title-left">
					<text>个人作品</text>
				</view>
			</view>
			<view class="">
				<view class="thumbial" v-for="(item,index) in castsList.works" :key="index">
					<!-- <navigator :url="'../detail/detail?id='+item.id"> -->
						<view class="thumbial-img">
							<image :src="item.subject.images.small" mode="widthFix"></image>
						</view>
						<view class="thumbial-body">
							<text>{{item.subject.title}}</text>
						</view>
					<!-- </navigator> -->
				</view>
			</view>
			<view class="summary-box">
				<view class="same-title wrap">
					<view class="title-left">
						<text>个人简介</text>
					</view>
				</view>
				<view class="summary wrap">{{castsList.summary}}</view>
			</view>
			<view class="photos">
				<view class="same-title wrap">
					<view class="title-left">
						<text>个人照片</text>
					</view>
				</view>
				<view class="thumbial other-thumbial" v-for="(item,index) in castsList.photos" :key="item.id">
					<!-- <navigator :url="'../casts/casts?id='+item.id"> -->
					<view class="thumbial-img" @tap="previewImg(index)">
						<image :src="item.cover" mode="widthFix"></image>
					</view>
						<!-- </navigator> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				castsList: [],
				photoList: []
			}
		},
		onLoad(options) {
			let castID = options.id;
			this.id = castID;
			this.getCasts()
		},
		methods: {
			getCasts: function() {
				var casts = global.BaseList.cast;
					this.$http.get(casts+'/'+this.id).then(res=>{
						this.castsList = res;
						console.log(this.castsList);
						for(var i=0;i<this.castsList.photos.length;i++){
							var obj = this.castsList.photos[i];
								this.photoList.push(obj.cover)
						}
					})
			},
			previewImg: function (index) {
				let imgArr = this.photoList;
				let indexs = index;
				uni.previewImage({
					urls: imgArr,
					current: indexs
				})
			}
		}
	}
</script>

<style>
	.cover{
		position: relative;
		height: 520upx;
		overflow: hidden;
		background-color: #EEEEEE;
	}
	.cover image{
		display: block;
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
	}
	.cover .cast-infor{
		position: absolute;
		bottom: 0;
		left: 0;
		padding: 20upx;
		width: 100%;
		background-color: rgba(0,0,0,0.4);
	}
	.cast-infor text{
		display: block;
		font-size: 40upx;
		color: orange;
	}
	.cast-infor .birthday{
		font-size: 28upx;
		color: #ddd;
	}
	.summary{
		font-size: 30upx;
		line-height: 22px;
		text-indent: 40upx;
		color: #444;
	}
	.thumbial{
		display: inline-block;
		width: 210upx;
	}
	.thumbial-img{
		height: 240upx;
	}
	.other-thumbial .thumbial-img{
		background-color: #fff;
	}
</style>
